home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / ShoveIt Deluxe™ by wsanchez / Install in _System_Demos / ShoveIt Deluxe / ShoveIt.app / Contents / Resources / script < prev   
Text File  |  2000-06-23  |  622b  |  39 lines

  1. #!/bin/sh
  2.  
  3. if [ -z "$1" ]; then exit; fi
  4.  
  5. if [ -z "$2" ] && [ -f "$1" ]; then
  6.     gzip -9 "$1";
  7.     exit
  8. fi
  9.  
  10. rootdir=$(dirname "$1")
  11. name=$(basename "$1").tar
  12.  
  13. if [ -f "$name" ] || [ -f "$name".gz ]; then
  14.     echo "File exists."
  15.     exit
  16. fi
  17.  
  18. cd "$rootdir"
  19.  
  20. for file; do
  21.     if ! echo "$1" | grep "$rootdir" > /dev/null 2>&1; then
  22.     echo "Crap!"
  23.     exit
  24.     fi
  25.  
  26.     if ! basefile=$(echo "$file" | sed 's|^'"$rootdir"'/||'); then
  27.     echo "Eit!"
  28.     exit
  29.     fi
  30.  
  31.     if [ -f "$basefile" ]; then
  32.     tar rf "$name" "$basefile" && rm -rf "$basefile"
  33.     else
  34.     tar cf "$name" "$basefile" && rm -rf "$basefile"
  35.     fi
  36. done
  37.  
  38. gzip -9 "$name"
  39.